package com.yjhb.android.sbz.fragment.mypromotionfrend;

import android.text.InputType;
import android.view.View;

import com.yjhb.android.sbz.entity.LevelUser;
import com.yjhb.android.sbz.fragment.BaseListFragment;
import com.yjhb.android.sbz.mvp.mypromotionfriend.MyPromotionFriendPresenter;
import com.yjhb.android.sbz.mvp.mypromotionfriend.MyPromotionFriendView;
import com.yjhb.android.sbz.tool.Tool;
import com.jojo.android.zxlib.base.BaseRecyclerAdapter;

import java.util.List;

/**
 * 创建者 zx
 * 创建时间 2020/12/30 14:52
 */
public abstract class BaseMyPromotionFriendFragment<RA extends BaseRecyclerAdapter> extends
        BaseListFragment<MyPromotionFriendPresenter, RA, LevelUser> implements MyPromotionFriendView {
    private final String TAG = "BaseMyPromotionFriend";


    @Override
    protected CharSequence getTips() {
        return null;
    }


    @Override
    protected MyPromotionFriendPresenter initPresenter() {
        return new MyPromotionFriendPresenter(this);
    }

    @Override
    protected void initUI() {
        super.initUI();
        search_layout.setVisibility(View.VISIBLE);
        search_et.setHint("请输入用户ID查询");
        search_et.setInputType(InputType.TYPE_CLASS_PHONE);
    }

    @Override
    public void onItemClick(int index, Object o) {

    }

    @Override
    public void onViewClick(View view, String msg, int index, Object o) {

    }


    protected abstract Integer getFriendType();


    @Override
    protected void onLoadData(int size, int current) {
        presenter.getRelationFriend(getFriendType(), Tool.getText(search_et, null), size, current);
    }

    @Override
    public void onLoad(List<LevelUser> levelUsers) {
        smartRefreshLayout.finishLoadmore();
        dataSet.addAll(levelUsers);
        adapter.notifyDataSetChanged();
    }

    @Override
    public void onRefresh(List<LevelUser> levelUsers) {
        loadingDialog.cancel();
        smartRefreshLayout.finishRefresh();
        dataSet.clear();
        dataSet.addAll(levelUsers);
        adapter.notifyDataSetChanged();
    }
}
